<?php

/**
 *
 * Created by allen.qiang <allen.qiang@fistforward.com>
 * Date: 15-1-8
 * Time: 下午4:24
 * FUN-AC-0028
 * 下午茶套餐
 */
quanli_require('module/base/system/itemHandler.class.php');//载入字典操作类
quanli_require('module/base/dunch/dunch.class.php');//载入下午茶操作类
class pa_dunch {

    public function execute() {
        global $G_SHOP ;

        if (isset($_REQUEST['operFlg'])) {

            switch($_REQUEST['operFlg']) {

                case 1: //下午茶套餐信息列表
                    $this->packagaList();
                    break;
                case 2://下午茶套餐列表
                    $this->dunchList();
                    break;
                case 3://下午茶会员&地址导入
                    $this->exportData();
                    break;
                default:
                    $G_SHOP->smarty->assign('error_msg', '参数错误，请审核后再操作');
                    $G_SHOP->smarty->display('comm/error.tpl');
            }
        }
    }


    /**
     * 下午茶套餐配置信息列表
     * @author allen.qiang
     */
    public function packagaList(){
        global $G_SHOP;
        $itemHandler=new itemHandler();
        $arg_array=array(
            'item'=>36
        );
        $dunchinfo=$itemHandler->searchItemList($arg_array);
        //获取下午茶咖啡信息
        $coffeeSKU= $dunchinfo[0]->itemName;
        $coffeeSql="select * from goods_sale where product_code in(".$coffeeSKU.")";
        $coffeeInfo=$G_SHOP->DBCA->stmt_query($coffeeSql);



        //获取下午茶蛋糕信息’
        $cakeSKU=$dunchinfo[1]->itemName;
        $cakeSql="select * from goods_sale where product_code in(".$cakeSKU.")";
        $cakeInfo=$G_SHOP->DBCA->stmt_query($cakeSql);



        $G_SHOP->smarty->assign('coffeeInfo',$coffeeInfo);
        $G_SHOP->smarty->assign('cakeInfo',$cakeInfo);


        $G_SHOP->smarty->display('dunch/packageList.tpl');
    }


    /*
     * 下午茶套餐列表
     * @author allen.qiang
     */
    public function dunchList(){
        global $G_SHOP;
        $dunch=new dunch();
        $dateArray=array();
        $dunchinfo=$dunch->searchPackage($dateArray);
        //error_log(print_r($dunchinfo,1));
        $G_SHOP->smarty->assign('dunchinfo',$dunchinfo);

        $G_SHOP->smarty->display('dunch/dunchList.tpl');
    }

    public function exportData()
    {
        global $G_SHOP;

        $G_SHOP->smarty->display('dunch/export.tpl');
    }


}
